home *** CD-ROM | disk | FTP | other *** search
/ PD ROM 1 / PD ROM Volume I - Macintosh Software from BMUG (1988).iso / Programming / Complete Applications / Screen Savers / Moire (Pascal) / MOIREINIT.PAS < prev   
Encoding:
Pascal/Delphi Source File  |  1986-10-22  |  2.3 KB  |  110 lines  |  [TEXT/ttxt]

  1. UNIT MOIREINIT;
  2.  
  3. INTERFACE
  4.  
  5.     USES MacIntf,MOIREGLOBALS,ZOOM;
  6.  
  7.     PROCEDURE Init;
  8.  
  9.     PROCEDURE MakeMenus;
  10.  
  11.     PROCEDURE MakeWindow;
  12.  
  13.     PROCEDURE LoseWindow (theWindow : WindowPtr);
  14.  
  15. IMPLEMENTATION
  16.  
  17.     PROCEDURE Init;
  18.         VAR
  19.             index : integer;
  20.     BEGIN
  21.         MaxApplZone;
  22.         FOR index := 1 TO 4 DO
  23.             MoreMasters;
  24.         InitGraf(@thePort);
  25.         InitFonts;
  26.         InitWindows;
  27.         InitMenus;
  28.         TEInit;
  29.         InitDialogs(NIL);
  30.         InitCursor;
  31.         FlushEvents(EveryEvent, 0);
  32.  
  33.         Step := 8;
  34.         CurrentPat := 3;
  35.         Flashing := FALSE;
  36.         SetDAFont(2);
  37.         flashRate := 120;
  38.         flashPhase := FALSE;
  39.     END;
  40.  
  41.     PROCEDURE MakeMenus;
  42.         VAR
  43.             appleCh : char;
  44.             index : integer;
  45.             menuStr : Str255;
  46.     BEGIN
  47.         appleCh := CHR($14);
  48.         AppleMenu := NewMenu(AppleID, appleCh);
  49.         AppendMenu(AppleMenu, 'About Moire...;(-');
  50.         AddResMenu(AppleMenu, 'DRVR');
  51.         InsertMenu(AppleMenu, 0);
  52.  
  53.         FileMenu := NewMenu(FileID, 'File');
  54.         AppendMenu(FileMenu, 'Quit/Q');
  55.         InsertMenu(FileMenu, 0);
  56.  
  57.         EditMenu := NewMenu(EditID, 'Edit');
  58.         AppendMenu(EditMenu, '(Undo/Z;(-;(Cut/X;(Copy/C;(Paste/V;(Clear');
  59.         InsertMenu(EditMenu, 0);
  60.  
  61.         PatMenu := NewMenu(PatMenuID, 'Pattern');
  62.         AppendMenu(PatMenu, 'Pen Pattern.../P;Step Value.../S;Invert/I;Flash');
  63.         CheckItem(PatMenu, FlashItem, FALSE);
  64.         InsertMenu(PatMenu, 0);
  65.  
  66.         DrawMenuBar;
  67.     END;
  68.  
  69.     PROCEDURE MakeWindow;
  70.         VAR
  71.             r1,r2,r3, cRect : rect;
  72.     BEGIN
  73.           setRect(r1,0,20,20,40);
  74.          setRect(r2,236,172,276,192);
  75.         setRect(r3, 20, 40, 492, 322);
  76.         myWindow := newWindow(NIL, r3, 'Moire Patterns', FALSE, 4, WindowPtr(-1), TRUE, 0);
  77.         cRect := myWindow^.portRect;
  78.         cRect.left := cRect.right - SBarWidth;
  79.         cRect.top := cRect.top + topLine - 1;
  80.         FlashControl := newControl(myWindow, cRect, '', TRUE, flashRate, 8, flashRate, 16, 0);
  81.         setPort(myWindow);
  82.         TextFont(4);
  83.         TextSize(9);
  84.         TextMode(srcCopy);
  85.         MoireRect := myWindow^.portRect;
  86.         MoireRect.top := MoireRect.top + topLine;
  87.         MoireRect.right := MoireRect.right - SBarWidth;
  88.          ZoomRect(r1,r2,TRUE);
  89.          ZoomRect(r2,r3,TRUE);
  90.         showWindow(myWindow);
  91.         WITH myWindow^.portRect DO
  92.             BEGIN
  93.                 LastPoint.h := (right - left) DIV 2;
  94.                 LastPoint.v := (bottom - top) DIV 2;
  95.             END;
  96.     END;
  97.  
  98.     PROCEDURE LoseWindow;
  99.     var
  100.         r1,r2,r3 : rect;
  101.     BEGIN
  102.         r3 := theWindow^.portRect;
  103.         setRect(r2,236,172,276,192);
  104.         setRect(r1,0,20,20,40);
  105.         HideWindow(theWindow);
  106.         ZoomRect(r2,r3,FALSE);
  107.         ZoomRect(r1,r2,FALSE);
  108.     END;
  109.  
  110. END.